import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import VueSetupExtend from "vite-plugin-vue-setup-extend";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import monacoEditorPlugin from "vite-plugin-monaco-editor";
// import MonacoWebpackPlugin from "monaco-editor-webpack-plugin";
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
export default defineConfig({
  base: "./",
  server: {
    port: 5173, // 端口号
    host: "0.0.0.0",
    open: "true",
    // 本地跨域代理. 目前注释的原因：暂时没有用途，server 端已经支持跨域
    proxy: {
      ["/api/gmtScript"]: {
        target: "http://10.222.125.103:18085",
        // ws: false,
        changeOrigin: true,
        rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
      },
      ["/api/gmtTask"]: {
        target: "http://10.222.125.103:18085",
        // ws: false,
        changeOrigin: true,
        rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
      },
      ["/api"]: {
        target: "http://10.222.125.103:18086",
        // ws: false,
        changeOrigin: true,
        rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
      },

      // 选项写法
    },
  },
  plugins: [
    vue(),
    VueSetupExtend(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    // MonacoWebpackPlugin(),
    // new MonacoWebpackPlugin({
    //   publicPath: '/node_modules/monaco-editor/min/vs'
    // }),
  ],
  optimizeDeps: {
    include: ["schart.js"],
  },
  resolve: {
    alias: {
      "@": "/src",
      "~": "/src/assets",
    },
  },
  define: {
    __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "true",
  },
});
